package apps.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import apps.web.controller.base.MyBaseCommandController;
import apps.web.model.Apply;

public class CheckApplyController extends MyBaseCommandController {

	@Override
	protected ModelAndView handleInner(HttpServletRequest request,
			HttpServletResponse response, Object command)
			throws RuntimeException {
		Apply apply = (Apply) command;
		apply = getServiceContainer().getApplyBizService().findApplyById(
				apply.getId());
		Map map = new HashMap();
		List<Apply> sameCodeList = getServiceContainer().getApplyBizService()
				.findApplyByApplyCode(apply.getApplyCode());
		List<Apply> sameExhNameList = getServiceContainer()
				.getApplyBizService().findApplyByApplyCode(apply.getExhName());

		sameCodeList.remove(apply);
		sameExhNameList.remove(apply);
		
		map.put("sameCodeList", sameCodeList);
		map.put("sameExhNameList", sameExhNameList);
		return new ModelAndView("CheckApplyCode.jsp", "map", map);
	}

}
